package com.vortex.cloud.sample.controller;

import com.vortex.cloud.sample.domain.TaskUser;
import com.vortex.cloud.sample.service.CommonService;
import com.vortex.cloud.sample.service.TaskUserService;
import com.vortex.cloud.sample.vo.TaskUserTreeDataVo;
import com.vortex.cloud.vfs.lite.base.dto.RestResultDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PipedReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 王林
 * @version 1.0
 * @date 2021-10-14 周四
 * @time 16:56
 * @description
 */
@Tag(name = "easyExcel导入导出", description = "excel文件导入导出")
@Validated
@CrossOrigin
@RestController
@RequestMapping("cloud/sample/api/v101/task/common")
public class CommonController {

    @Resource
    private CommonService commonService;


    @Operation(summary = "导入excel表")
    @PostMapping(value = "/ImportExcel11", consumes = "multipart/form-data")
    public RestResultDTO<String> importExcel(@RequestPart(value = "file") MultipartFile file) throws IOException {
        return commonService.importExcel(file);
    }

    @Operation(summary = "导出excel表")
    @GetMapping(value = "/exportExcel")
    public RestResultDTO<String> exportExcel(HttpServletResponse response) throws Exception {
        return commonService.exportExcel(response);
    }



}
